<style scoped lang="less" rel="stylesheet/scss">
    @import '../styles/common.scss';
    @import '../styles/app.scss';
    
</style>

<template>
    <div class="content-box">
        <div class="b-leftMenu">
            <img src="../images/logo.png"/>
            <div class="nav-item" v-for="item in items2">
                <span>{{item.name}}</span>
                <a v-link="{path: i.path}" v-for="i in item.sub">{{i.name}}</a>
            </div>
        </div>
        <div class="b-rightContent">
            <router-view></router-view>
        </div>
    </div>
</template>
<script>
    export default {
        data () {
            return {
                items: [
                    {
                        name: '产品管理',
                        sub:[
                            {name:"公司产品汇总",path:"/appSale/productList"},
                        ]
                    },
                    {
                        name: '客户管理',
                        sub:[
                            {name:"我的客户",path:"/appSale/client"},
                            {name:"客户业务用量",path:"/appSale/clientManage"},
                            {name:"客户业务详情",path:"/appSale/clientDetail"}
                        ]
                    },
                ],
            };
        },
        computed:{
            items2(){
                if(this.store.roll!=='1'){
                    let dataTemp=this.items;
                    dataTemp[1].sub[0].name='全部客户';
                    return dataTemp;
                }else{
                    return this.items;
                }
            }
        },
        methods:{
            getPro(){
                this.$http.jsonp(this.path+'product/productServlet/productList',{
                    params:{page:1,
                            rows:200,},
                    jsonp:'callback'
                }).then(
                    (datas)=>{
                        if(datas.body.code=='001'){
                            this.store.allPro=datas.body.result.rows;
                        }else if(datas.body.code=='002'){
                            this.$Message.success('提交信息出错p!');
                        }else if(datas.body.code=='997'||datas.body.code=='998'){
                            this.store.state.user.companyId=null;
                            this.store.state.user.companyName=null;
                            this.store.state.allInfor=null;
                            this.$Message.error('登陆超时或未登陆,请登陆!');
                            this.myRouter.go({path:'/login'});
                        }
                    },
                    (error)=>{
                        this.$Message.success('网络问题!');
                    }   
                );
            },
            getClient(){
                this.$http.jsonp(this.path+'company/companyDownServlet/CompanylistByRole',{
                    params:{page:1,
                            rows:200,},
                    jsonp:'callback'
                }).then(
                    (datas)=>{
                        if(datas.body.code=='001'){
                            this.store.allClient=datas.body.result.rows;
                        }else if(datas.body.code=='002'){
                            this.$Message.success('提交信息出错p!');
                        }else if(datas.body.code=='997'||datas.body.code=='998'){
                            this.store.state.user.companyId=null;
                            this.store.state.user.companyName=null;
                            this.store.state.allInfor=null;
                            this.$Message.error('登陆超时或未登陆,请登陆!');
                            this.myRouter.go({path:'/login'});
                        }
                    },
                    (error)=>{
                        this.$Message.success('网络问题!');
                    }   
                );
         
            },
        },
        ready(){
            this.getPro();
            this.getClient();
        }
    }
</script>
